﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace MINERP.DAL.PrintManage
{
    public class DALSearch
    {
        private static Database db = DatabaseFactory.CreateDatabase();

        //barcode search function
        public static void GetBarCodeResultTable(int barCode, out DataSet dt)
        {
            try
            {
                string sqlStr = "GetPhotosinfoByBarcode";
                DbCommand dbCommand = db.GetStoredProcCommand(sqlStr);
                db.AddInParameter(dbCommand, "barcode", DbType.Int32, barCode);

                dt = db.ExecuteDataSet(dbCommand);
            }
            catch
            {
                throw;
            }
        }


        //boardid search function
        public static void GetBoardIDResultTable(int boardID, out DataSet dt)
        {
            try
            {
                string sqlStr = "GetPhotoInfoByBoardID";
                DbCommand dbCommand = db.GetStoredProcCommand(sqlStr);
                db.AddInParameter(dbCommand, "boardid", DbType.Int32, boardID);

                dt = db.ExecuteDataSet(dbCommand);
            }
            catch
            {
                throw;
            }

        }

        //orderid search function
        public static void GetOrderidResultTable(string ordercode, out DataSet dt)
        {
            try
            {
                string sqlStr = "GetPhotosinfoByOrderCode";
                DbCommand dbCommand = db.GetStoredProcCommand(sqlStr);
                db.AddInParameter(dbCommand, "ordercode", DbType.String, ordercode);

                dt = db.ExecuteDataSet(dbCommand);
            }
            catch
            {
                throw;
            }
        }       
    }
}
